/*
 * VisualDiagramComponent.h
 *
 *  Created on: May 28, 2013
 *      Author: root
 */

#ifndef VISUALDIAGRAMCOMPONENT_H_
#define VISUALDIAGRAMCOMPONENT_H_

#include "gui/VisualComponents/VisualCompositeComponent.h"
#include "model/der/ComponentDER.h"
#include "gui/VisualComponents/VisualComponent.h"
#include "gui/VisualComponents/VisualComponentConector.h"
#include "xml/XmlReader.h"
#include "xml/XmlWriter.h"
#include "model/Diagram.h"


class VisualDiagramComponent : public VisualCompositeComponent {
public:
	VisualDiagramComponent(Diagram* diagram);
	VisualDiagramComponent(const VisualDiagramComponent &other);
	virtual ~VisualDiagramComponent();

    virtual VisualDiagramComponent *getCopy(Diagram* diagram) { m_diagram = diagram; return NULL;}

    Component *getComponent() {  return m_component;}
    Diagram* getDiagram() { return m_diagram;}

    void setX(int x) { m_component->setX(x);}
    void setY(int y) { m_component->setY(y);}
    int getX() const { return m_component->getX();}
    int getY() const { return m_component->getY();}

//	virtual void load(XmlReader& reader, Diagram* diagram);
	virtual void load(XmlReader& reader, XmlReader& readerModel, Diagram* diagram);
	virtual void store(XmlWriter& writer_rep, XmlWriter& writer_comp, Diagram* diagram) = 0;
	virtual void update() = 0;
	virtual void showProperties() = 0;

    virtual void on_move(int mouseX, int mouseY);
    virtual void on_expose(Cairo::RefPtr<Cairo::Context> ptrContext);

    virtual VisualComponentConector *getConectorLibre();
    virtual VisualComponentConector *getConectorEnIndice(unsigned int i) {return conectoresEntrantes[i];};

    bool showConnectors;

protected:
    std::vector<VisualComponentConector *> conectoresEntrantes;
    std::vector<VisualComponentConector *> conectoresSalientes;

    Component *m_component;
    Diagram* m_diagram;

    void initialize();
};

#endif /* VISUALDIAGRAMCOMPONENT_H_ */
